package com.example.laboratory.ui.home;

        import android.app.Dialog;
        import android.content.Intent;
        import android.util.Log;
        import android.view.Gravity;
        import android.view.View;
        import android.view.Window;
        import android.view.WindowManager;
        import android.widget.AbsListView;
        import android.widget.TextView;
        import com.example.laboratory.R;
        import com.example.laboratory.application.LApp;
        import com.example.laboratory.bean.Laboratory;
        import com.example.laboratory.manager.UserInfoManager;
        import com.example.laboratory.net.callback.RxObserver;
        import com.example.laboratory.ui.SecureCheck.SeCheckActivity;
        import com.example.laboratory.ui.base.BaseFragment;
        import com.example.laboratory.ui.dialog.SingleSelectDialog;
        import com.example.laboratory.ui.main.MainActivity;
        import com.example.laboratory.ui.user.Laboratory.LabContract;
        import com.example.laboratory.ui.user.Laboratory.LabListActivity;
        import com.example.laboratory.ui.user.Laboratory.LabPresenter;
        import com.example.laboratory.utils.GlideImageLoader;
        import com.example.laboratory.utils.IntentUtils;
        import com.youth.banner.Banner;
        import com.youth.banner.BannerConfig;
        import com.youth.banner.Transformer;

        import java.util.ArrayList;
        import java.util.List;

public class HomeFragment extends BaseFragment implements View.OnClickListener {
    private static List<Integer> bannerImages = new ArrayList<>();
    private View rootView = null;
    private TextView tv_home_secure_check;
    private LApp lApp;
    static {
        bannerImages.add(R.drawable.banner_1);
        bannerImages.add(R.drawable.banner_3);
        bannerImages.add(R.drawable.banner_4);
    }


    @Override
    protected void initViews(View view) {
        this.rootView=view;
        tv_home_secure_check=rootView.findViewById(R.id.home_secure_check);
        BannerLooper();
        tv_home_secure_check.setOnClickListener(this);
        lApp= (LApp)getActivity().getApplication();
        Log.d("ZZZ",lApp+"");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_home;
    }

    private void BannerLooper() {
        Banner banner = (Banner) rootView.findViewById(R.id.banner);
        //设置banner样式
        //banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        banner.setImages(bannerImages);
        //设置banner动画效果
        banner.setBannerAnimation(Transformer.DepthPage);
        //设置标题集合（当banner样式有显示title时）
        // banner.setBannerTitles(titles);
        // banner.setti
        //设置自动轮播，默认为true
        banner.isAutoPlay(true);
        //设置轮播时间
        banner.setDelayTime(3000);
        //设置指示器位置（当banner模式中有指示器时）
        banner.setIndicatorGravity(BannerConfig.CENTER);
        //banner设置方法全部调用完毕时最后调用
        banner.start();
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.home_secure_check:
                SecureCheck();

                break;

        }
    }


    private void SecureCheck(){
        List<Laboratory.RowsBean> list=new ArrayList<>();
        list=lApp.getRowsBeans();

        Dialog dialog=new SingleSelectDialog(rootView.getContext(),list);
        dialog.show();
    }
}

